@echo off

echo WEI.ZHOU Compile and edit the shutdown script 2023

setlocal enabledelayedexpansion

set PORT=8100

:: 查询指定端口上的PID
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%PORT%"') do (
    set PID=%%a
    goto :KillProcess
)

echo No process found on port %PORT%.
goto :End

:KillProcess
:: 终止指定PID的进程
taskkill /F /PID %PID%

echo The process %PID% has been terminated.

:End
endlocal

pause